
<div class="login-box">
    <!-- 登录框 -->
    <form class="layui-form "  method="post">
        <div class="login-container">
            <div class="layui-form-item">
                <div class="layui-input-wrap">
                    <div class="layui-input-prefix">
                        <i class="layui-icon layui-icon-username"></i>
                    </div>
                    <input type="text" name="uname" value="" lay-verify="required" placeholder="用户名"
                           lay-reqtext="请填写用户名" autocomplete="off" class="layui-input" lay-affix="clear" id="uname">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-wrap">
                    <div class="layui-input-prefix">
                        <i class="layui-icon layui-icon-password"></i>
                    </div>
                    <input type="password" name="upwd" value=""
                           placeholder="密   码" class="layui-input"
                           lay-affix="eye" id="upwd">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row">
                    <div class="layui-col-xs7">
                        <div class="layui-input-wrap">
                            <div class="layui-input-prefix">
                                <i class="layui-icon layui-icon-vercode"></i>
                            </div>
                            <!-- 120*40验证码大小 -->
                            <input type="text"  name="yzm" value="" placeholder="验证码" class="layui-input" >
                        </div>
                    </div>
                    <div class="layui-col-xs5">

                        <div style="margin-left: 10px;">
                        <!--                验证码位置           -->
                            <img src="{:captcha_src()}" alt="captcha" style="width: 120px;height: 40px" />
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <input type="checkbox" name="remember" lay-skin="primary" title="记住密码">
                <a href="form.html#forget" style="float: right; margin-top: 7px;">忘记密码？</a>
            </div>
            <div class="layui-form-item">
                <input type="button" class="layui-btn layui-btn-fluid" id="btnlogin" value="登录"></input>
            </div>
            <div class="layui-form-item login-other">
                <label>社交账号登录</label>
                <span style="padding: 0 21px 0 6px;">
                                <a href="javascript:;"><i class="layui-icon layui-icon-login-qq"
                                                          style="color: #3492ed;"></i></a>
                                <a href="javascript:;"><i class="layui-icon layui-icon-login-wechat"
                                                          style="color: #4daf29;"></i></a>
                                <a href="javascript:;"><i class="layui-icon layui-icon-login-weibo"
                                                          style="color: #cf1900;"></i></a>
                            </span>
                或 <a href="/index.php/login/register">注册帐号</a></span>
            </div>
        </div>
    </form>
</div>
<script>
   // 登录的事件
   $("#btnlogin").click(function (){
       // alert(111)
       // 这里需要注意的就是请求的url
       if($("#uname").val()==""){
           layer.msg("请输入用户名！")
       }else if($("#upwd").val()==""){
           layer.msg("请输入密码！")
       }else if($("input[name='yzm']").val()==""){
           layer.msg("请输入验证码！")
       }else{
           $.post("/index.php/index/loginCheck", {
               "uname":$("#uname").val(),
               "upwd":$("#upwd").val(),
               "yzm":$("input[name='yzm']").val()
           },function (data,status) {
               // layer.msg(data+"状态"+status)
               if(data==1){
                   layer.msg("登录成功");
                   window.location.href= "/index.php/index/index"
               }else if(data==2) {
                   layer.msg("不存在该用户")
               }else if(data==3){
                   layer.msg("密码错误")
               }else if(data==4){
                   layer.msg("验证码错误")
               }
           })
       }

   })





</script>
